home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Graphics / SMan / WarpOS / Source / ULP4.asm < prev    next >
Encoding:
Assembly Source File  |  2001-03-26  |  3.5 KB  |  143 lines

  1. #Most comments from ULP2.asm and ULP3.asm apply here as well.
  2.  
  3.  
  4.  
  5.     .global    @__UseLibP4
  6.     .text
  7.     .sdreg    r2
  8.     .global    _UseLibP4
  9.     .align    4
  10. _UseLibP4:
  11.     mflr    r11
  12.     stw    r11,8(r1)    #Save return address
  13.     stwu    r1,-96(r1)      #Save stack pointer
  14.     fmr    f16,f1        #Transfer yrel from f1 to f16
  15.     lwz    r24,_MaxCnt(r2)        #MaxCnt in r24.
  16.     lwz    r25,_LPixelBuf(r2)    #Get Location of LPixelBuf
  17.     lwz    r27,_ColorTable32(r2)    #Start of color table
  18.     lwz    r28,_BPP(r2)             #Number bytes per pixel
  19.     lfd    f25,_Factor(r2)    #Get Factor into f25
  20.     lfd    f22,_Two(r2)    #Get Two into f22 as constant
  21.     lfd    f23,_Limit(r2)    #Get Limit into f23 as constant
  22.     fadd    f14,f22,f22    #f14 is 4.
  23. #    fadd    f14,f14,f22    #f14 is 6.
  24. #    fdiv    f14,f14,f22    #f14 is 3.
  25.  
  26. #    f14 is 3.0
  27.  
  28. #    Use f27 as intermediate value in calculation of Zr4.
  29.  
  30. #The above could have been done with a global definition of 3.000.
  31.  
  32.     fsub    f15,f22,f22    #(float)xtemp = 0.
  33.     lfd    f10,_XCenter(r2)#f10 = XCenter
  34.     li    r30,0        #xtemp = 0.
  35.     fsub    f15,f15,f10    #xRel = xRel - XCenter
  36.     fdiv    f18,f15,f25    #xRel = xRel/Factor
  37.  
  38.     lfd    f21,_DX(r2)    #Get the real value of Delta x.
  39.     lwz    r29,_RightEdge(r2)
  40. #    fmr    f17,f16
  41. Start:
  42.     fmr    f15,f18        #Initial value of Zr is xRel
  43.  
  44. #  The following line was moved before rather than after fmr f17,f16
  45. #  to give the fpu a break.
  46.     li    r23,1        #Initialize CurCnt = 1
  47.     fmr    f17,f16        #yRel into f17 as initial Zi.
  48.     b    l3        #Check to see if to MaxCnt
  49. l2:
  50.     fmul    f24,f15,f15    #Zr2 in f24
  51.     fmul    f4,f17,f17    #Zi2 = Zi*Zi
  52.     fadd    f19,f24,f4      #Zr2 + Zi2 -> f19
  53.     fcmpu    cr0,f19,f23    #Compare with Limit in f23.
  54.     ble    cr0,l6
  55.  
  56. #The following section is not very time-critical as it is only reached once.
  57. #for each pixel
  58.     cmpwi    cr0,r28,2    #See if BPP < 2
  59.     blt    cr0,l8
  60. l7:
  61.     slwi    r10,r23,2    #4 times CurCnt for offset in ColorTable32
  62.     add    r26,r27,r10    #Find location of pixel color in ColorTable32
  63.     lwz    r11,0(r26)    #Get ARGB from ColorTable
  64.     stw    r11,0(r25)    #Store color in LPixelBuf
  65.     addi    r25,r25,4    #Point to next location in LPixelBuf
  66.     b    l1
  67. l8:    andi.    r3,r23,65535    #Color into r3 as UWORD for PlotIt
  68.     bl    _PlotIt
  69. l9:    b    l1
  70. l6:
  71.     fmul    f20,f24,f14    #Find 4*Zr2
  72.  
  73.     fsub    f27,f24,f4    #Find Zr2 - Zi2            ***
  74.  
  75.     fmul    f20,f20,f4    #Now have 4*Zr2*Zi2
  76.  
  77.     fmul    f28,f27,f27    #Square above
  78.     fmul    f27,f27,f14    #4*(Zr2 - Zi2)
  79.     fsub    f28,f28,f20    #Now have (Zr2-Zi2)^2 -4*Zr2*Zi2->Zr2 as f28.
  80.  
  81.     fmul    f27,f27,f17    #4*(Zr2 - Zi2)*Zi
  82.     addi    r23,r23,1       #Increment CurCnt
  83.     fmul    f17,f27,f15    #4*(Zr2 - Zi2)*Zi*Zr -> Zi
  84.  
  85.     fadd    f15,f18,f28     #New Zr = xRel + Zr2
  86.     fadd    f17,f16,f17    #Zi = Zi + yRel
  87.  
  88. l3:
  89.     cmpw    cr0,r23,r24    #See if CurCnt < MaxCnt
  90.     blt    cr0,l2        #Repeat until MaxCnt reached
  91.  
  92.     cmpwi    cr0,r28,2    #See if BPP < 2
  93.     blt    cr0,l11
  94. l10:
  95.  
  96.     lis    r12,4
  97.     addi    r12,r12,-4
  98.     add    r26,r27,r12    #Find location of pixel color
  99.     lwz    r11,0(r26)      #Get color
  100.  
  101.     stw    r11,0(r25)    #Store color in LPixelBuf
  102.     addi    r25,r25,4    #Point to next pixel in buffer
  103.     b    l1        #Was l12
  104. l11:
  105.     lis    r11,1
  106.     addi     r3,r11,-1    #ffff into r3 for PlotIt
  107.     bl    _PlotIt
  108. l1:
  109.     fadd    f18,f18,f21    #Find new value of xRel (xRel = xRel + DX).
  110.     addi    r30,r30,1    #Increment xtemp.
  111.     cmpw    cr0,r30,r29    #See if to RightEdge
  112.  
  113.     blt    cr0,Start    #Repeat until row is done.
  114.     stw    r25,_LPixelBuf(r2)  #New location in long pixel buffer
  115.     addi    r1,r1,96        #Balance Stack pointer
  116.     lwz    r11,8(r1)    #Get return address
  117.     mtlr    r11
  118.     fmr    f1,f20
  119.  
  120.     blr
  121.     .type    _UseLibP4,@function
  122.     .size    _UseLibP4,$-_UseLibP4
  123.  
  124.     .global    _MaxCnt
  125.     .global    _RightEdge
  126.     .global    _XCenter
  127.     .global    _Factor
  128.     .global    _Limit
  129.     .global    _Two
  130. #    .global _Three
  131.     .global    _LPixelBuf
  132.     .global    _ColorTable32
  133.     .global    _BPP
  134.     .global    _DX
  135.     .global    _PlotIt
  136.     .global    @__PlotIt
  137.  
  138. #    .tocd
  139. #    .align    3
  140. #l13:
  141. #    .long    0x43300000,0x80000000
  142. #l14:    .word    0
  143. #l15:    .word    0